/*     */ package com.zimbra.cs.account.ldap.upgrade;
/*     */ 
/*     */ import com.zimbra.common.service.ServiceException;
/*     */ import com.zimbra.common.util.StringUtil;
/*     */ import com.zimbra.cs.account.Config;
/*     */ import com.zimbra.cs.account.Entry;
/*     */ import com.zimbra.cs.account.Server;
/*     */ import com.zimbra.cs.account.ldap.LdapProv;
/*     */ import com.zimbra.cs.ldap.LdapClient;
/*     */ import com.zimbra.cs.ldap.LdapServerType;
/*     */ import com.zimbra.cs.ldap.LdapUsage;
/*     */ import com.zimbra.cs.ldap.ZLdapContext;
/*     */ import java.util.HashMap;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class BUG_57425
/*     */   extends UpgradeOp
/*     */ {
/*     */   void doUpgrade()
/*     */     throws ServiceException
/*     */   {
/*  38 */     ZLdapContext zlc = LdapClient.getContext(LdapServerType.MASTER, LdapUsage.UPGRADE);
/*     */     try {
/*  40 */       doGlobalConfig(zlc);
/*  41 */       doAllServers(zlc);
/*     */     } finally {
/*  43 */       LdapClient.closeContext(zlc);
/*     */     }
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   private void doEntry(ZLdapContext zlc, Entry entry, String entryName)
/*     */     throws ServiceException
/*     */   {
/*  53 */     String SMIMECertificate = "SMIMECertificate";
/*     */     
/*  55 */     String attrName = "zimbraContactHiddenAttributes";
/*     */     
/*  57 */     this.printer.println();
/*  58 */     this.printer.println("Checking " + entryName);
/*     */     
/*  60 */     String curValue = entry.getAttr(attrName, false);
/*     */     
/*     */     boolean needsUpdate;
/*     */     
/*  64 */     if (curValue == null) { boolean needsUpdate;
/*  65 */       if ((entry instanceof Config)) {
/*  66 */         needsUpdate = true;
/*     */       }
/*     */     }
/*     */     else
/*     */     {
/*  71 */       needsUpdate = !curValue.contains("SMIMECertificate");
/*     */     }
/*     */     
/*  74 */     if (needsUpdate) {
/*     */       String newValue;
/*     */       String newValue;
/*  77 */       if (curValue == null) {
/*  78 */         newValue = "SMIMECertificate";
/*     */       } else {
/*  80 */         newValue = curValue + "," + "SMIMECertificate";
/*     */       }
/*     */       
/*  83 */       Map<String, Object> attrs = new HashMap();
/*  84 */       StringUtil.addToMultiMap(attrs, attrName, newValue);
/*  85 */       modifyAttrs(entry, attrs);
/*     */     } else {
/*  87 */       this.printer.println("    " + attrName + " already has an effective value: [" + curValue + "] on entry " + entryName + " - skipping");
/*     */     }
/*     */   }
/*     */   
/*     */   private void doGlobalConfig(ZLdapContext zlc) throws ServiceException {
/*  92 */     Config config = this.prov.getConfig();
/*  93 */     doEntry(zlc, config, "global config");
/*     */   }
/*     */   
/*     */   private void doAllServers(ZLdapContext zlc) throws ServiceException {
/*  97 */     List<Server> servers = this.prov.getAllServers();
/*     */     
/*  99 */     for (Server server : servers) {
/* 100 */       doEntry(zlc, server, "server " + server.getName());
/*     */     }
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/account/ldap/upgrade/BUG_57425.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */